package service.Impl;

import dao.StuDao;
import dao.impl.StuDaoImpl;
import domain.Stu;
import domain.Student;
import service.StuService;

import java.util.List;

public class StuServiceImpl implements StuService {
    private StuDaoImpl stuDao=new StuDaoImpl();
    @Override
    public void add(Stu stu) {
        stuDao.add(stu);
    }

    @Override
    public void delete(int ID,String course) {
        stuDao.delete(ID,course);
    }

    @Override
    public void update(Stu stu) {
        stuDao.update(stu);
    }

    @Override
    public List<Stu> findAll() {
        return stuDao.findAll();
    }

    @Override
    public List<Stu> findByIdOrCourse(Stu student) {
        if(student.getID()!=0&&student.getCourse()==null){
            return stuDao.findById(student.getID());
        }
        if(student.getID()==0&&student.getCourse()!=null){
            return stuDao.findByCourse(student.getCourse());
        }
        else
            return stuDao.findByIdAndCourse(student.getID(),student.getCourse());
    }

    @Override
    public Stu findByRow(int row) {
        Stu byRow = stuDao.findByRow(row);
        return byRow;
    }

	@Override
	public List<String> findAllCourse() {
		return stuDao.findAllCourse();
	}

	@Override
	public List<String> findAllClasses() {
		return stuDao.findAllClasses();
	}

	@Override
	public List<Stu> findAllStu() {
		
		return stuDao.findAllStu();
	}

	@Override
	public String findAvgCourse(String course) {
		return stuDao.findAvgCourse(course);
	}

	@Override
	public String findMaxCourse(String course) {
		return stuDao.findMaxCourse(course);
	}

	@Override
	public String findMinCourse(String course) {
		return stuDao.findMinCourse(course);
	}

	@Override
	public String findAvgPerson(int id) {
		return stuDao.findAvgPerson(id);
	}

	@Override
	public String findSumPerson(int id) {
		return stuDao.findSumPerson(id);
	}

}
